<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理系统</title>
<link href="admin/css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/tools/jquery-1.4.2.min.js"></script>
<style type="text/css">
<!--
body {
	background-color: #ECEEF0;
	background-image: url(images/main_01.gif);
}
-->
</style>
<script>
function loginUser()
	 {
	 	var username=$.trim($("#loginusername").val());
	    var password=$.trim($("#loginpassword").val());
		var validateCode=$.trim($("#validateCode").val());
		if(username=="")
		{
			alert("用户名不能为空！");
			return false;
		}else if(password=="")
		{
			alert("密码不能为空！");
			return false;
		}else if(validateCode==""||validateCode.length!=4)
		{
			alert("验证码不正确！");
			return false;
		}
		
		 $.getJSON("image!checkValidateCode.action",{'validateCode':validateCode},function(data){
		 	           if(data.info)
							{
								 $.getJSON("user!loginUser.action",{'user.email':username,"user.password":password,"ajax":"ajax"},function(data){
								    if(data.info)
									{
										window.location.href="admin/adminindex.jsp";
									}else
									{
										alert("登录失败");
									}
								});
							}else
							{
								alert("验证码不正确！");
							}
			});
	 }
//改变验证码
	 function changeValidateCode(obj)
	 {
	 	$(obj).attr("src","image!validateCode.action?times="+new Date().getTime())
	 }
</script>
</head>

<body>
<div id="m_container">
  <div id="m_PageBody">
  <div class="m_pbox">
  <div class="boxlefe">
  <div class="lefttit"><img src="images/main_25.gif" width="270" height="62" /></div>
  <div class="leftcent"><div class="login">
    <table width="470" border="0" cellspacing="0" cellpadding="0" >
      <tr>
        <td width="83" rowspan="3" align="left"><img src="images/main_38.gif" width="76" height="32" style="float:left;" /></td>
        <td width="127" height="30" align="center" style="padding-top:10px" ><strong>Email:</strong>&nbsp;&nbsp;</td>
        <td width="260" align="left" valign="middle" style="padding-top:10px"><input id="loginusername" type="text" class="input" maxlength="80" /></td>
      </tr>
      <tr>
        <td width="127" height="30" align="center" style="padding-top:10px" ><strong>密&nbsp;&nbsp;&nbsp;码:</strong>&nbsp;&nbsp;</td>
        <td align="left" valign="middle"><input id="loginpassword" type="password" class="input" maxlength="80" /></td>
      </tr>
      <tr>
       <td width="127" height="30" align="center" style="padding-top:10px" ><strong>验证码:</strong>&nbsp;&nbsp;</td>
        <td align="left" valign="middle"><input id="validateCode" type="text" style="width: 30px;" class="input" size="4" maxlength="4" />&nbsp;&nbsp;<img src="image!validateCode.action" style="cursor:pointer;" onclick="changeValidateCode(this)" width="60" height="20" align="absmiddle"/></td>
      </tr>
    </table>
  </div>
  </div>
  <div class="leftbott"><img src="images/main_56.gif" width="37" height="28" align="absmiddle" />&nbsp;&nbsp;请输入正确的用户名及密码进行登录，即可自助管理您的网站!</div>
  </div>
  <div class="boxright">
  <div class="rightb"></div>
  <div class="rightlog"><img src="images/main_33.gif" style="cursor:pointer;"  onclick="loginUser()" width="100" height="63" border="0" /></div>
  </div>
  </div>
  <div class="Copyright">
    <div class="font"></div>
  </div>
  </div>
</div>
</body>
</html>
